package com.utils;

import com.ql.pojo.yk.Doctor;
import com.ql.service.doctor.DoctorService;
import com.ql.utils.SessionUtils;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.TaskListener;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import javax.servlet.http.HttpServletRequest;

public class TaskListenerImpl implements TaskListener {
    public void notify(DelegateTask delegateTask) {
        Doctor doctor = SessionUtils.getCurrentUser();
        Integer lingdao = doctor.getLingdao();
        HttpServletRequest request = SessionUtils.getCurrentServletRequest();
        ApplicationContext applicationContext = WebApplicationContextUtils
                .getWebApplicationContext(request.getServletContext());
        DoctorService doctorService= applicationContext.getBean(DoctorService.class);
        Doctor doctor1 = doctorService.selectById(lingdao);
        delegateTask.setAssignee(doctor1.getDocname());

    }
}
